package logic

import (
	"context"
	"huiyun/huiyunrpc/huiyunrpc"
	"huiyun/huiyunrpc/internal/svc"
	"huiyun/model/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type ReplyListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReplyListLogic {
	return &ReplyListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 回复列表
func (l *ReplyListLogic) ReplyList(in *huiyunrpc.ReplyListRequest) (*huiyunrpc.ReplyListResponse, error) {
	// todo: add your logic here and delete this line
	var reply []mysql.Reply
	mysql.DB.Debug().Find(&reply)
	var replylist []*huiyunrpc.ReplyList
	for _, m := range reply {
		list := huiyunrpc.ReplyList{
			SportId: m.SportId,
			UserId:  m.UserId,
			Content: m.Content,
		}
		replylist = append(replylist, &list)
	}
	return &huiyunrpc.ReplyListResponse{
		List: replylist,
	}, nil
}
